﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;

namespace Top.UpLoad
{
    public class UpLoad
    {
        public static string UpLoadFile()
        {
            HttpRequest request = System.Web.HttpContext.Current.Request;
            HttpFileCollection FileCollect = request.Files;
            if (FileCollect.Count > 0)  //如果集合的数量大于0
            {
                foreach (string str in FileCollect)
                {
                    HttpPostedFile file = FileCollect[str];  //用key获取单个文件对象HttpPostedFile
                    UpLoadHelper upFiles = new UpLoadHelper();
                    //返回成功信息
                    return upFiles.fileSaveAs(file, true);
                }
            }

            return "{\"msg\": 0, \"msgbox\": \"请选择上传文件！\"}";
        }
    }
}
